home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH18 / KEYRPT.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-07-15  |  2.6 KB  |  159 lines

  1. ; This program reads the file created by the KEYEVAL.EXE TSR program.
  2. ; It displays the log containing dates, times, and number of keystrokes.
  3.  
  4.         .xlist
  5.         .286
  6.         include     stdlib.a
  7.         includelib    stdlib.lib
  8.         .list
  9.  
  10. dseg        segment    para public 'data'
  11.  
  12. FileHandle    word    ?
  13.  
  14. month        byte    0
  15. day        byte    0
  16. year        word    0
  17. hour        byte    0
  18. minute        byte    0
  19. second        byte    0
  20. KeyStrokes    word    0
  21. RecSize        =    $-month
  22.  
  23. dseg        ends
  24.  
  25.  
  26.  
  27.  
  28. cseg        segment    para public 'code'
  29.         assume    cs:cseg, ds:dseg
  30.  
  31. ; SeeIfPresent-    Checks to see if our TSR is present in memory.
  32. ;        Sets the zero flag if it is, clears the zero flag if
  33. ;        it is not.
  34.  
  35. SeeIfPresent    proc    near
  36.         push    es
  37.         push    ds
  38.         pusha
  39.         mov    cx, 0ffh        ;Start with ID 0FFh.
  40. IDLoop:        mov    ah, cl
  41.         push    cx
  42.         mov    al, 0            ;Verify presence call.
  43.         int    2Fh
  44.         pop    cx
  45.         cmp    al, 0            ;Present in memory?
  46.         je    TryNext
  47.         strcmpl
  48.         byte    "Keypress Logger TSR",0
  49.         je    Success
  50.  
  51. TryNext:    dec    cl            ;Test USER IDs of 80h..FFh
  52.         js    IDLoop
  53.         cmp    cx, 0            ;Clear zero flag.
  54. Success:    popa
  55.         pop    ds
  56.         pop    es
  57.         ret
  58. SeeIfPresent    endp
  59.  
  60.  
  61.  
  62. Main        proc
  63.         meminit
  64.  
  65.         mov    ax, dseg
  66.         mov    ds, ax
  67.  
  68.  
  69.  
  70.         argc
  71.         cmp    cx, 1            ;Must have exactly 1 parm.
  72.         je    GoodParmCnt
  73.         print
  74.         byte    "Usage:",cr,lf
  75.         byte    "       KEYRPT filename",cr,lf,0
  76.         ExitPgm
  77.  
  78.  
  79.  
  80. GoodParmCnt:    mov    ax, 1
  81.         argv
  82.  
  83.         print
  84.         byte    "Keypress logger report program",cr,lf
  85.         byte    "Processing file:",0
  86.         puts
  87.         putcr
  88.  
  89.         mov    ah, 3Dh            ;Open file command.
  90.         mov    al, 0            ;Open for reading.
  91.         push    ds
  92.         push    es                ;Point ds:dx at name
  93.         pop    ds
  94.         mov    dx, di
  95.         int    21h            ;Open the file
  96.         jnc    GoodOpen
  97.         print
  98.         byte    "DOS error #",0
  99.         puti
  100.         print
  101.         byte    " opening file.",cr,lf,0
  102.         ExitPgm
  103.  
  104. GoodOpen:    pop    ds
  105.         mov    FileHandle, ax        ;Save file handle.
  106.  
  107.  
  108. ; Okay, read the data and display it:
  109.  
  110. ReadLoop:    mov    ah, 3Fh            ;Read file command
  111.         mov    bx, FileHandle
  112.         mov    cx, RecSize        ;Number of bytes.
  113.         mov    dx, offset month    ;Place to put data.
  114.         int    21h
  115.         jc    ReadError
  116.         test    ax, ax            ;EOF?
  117.         je    Quit
  118.  
  119.         mov    cx, year
  120.         mov    dl, day
  121.         mov    dh, month
  122.         dtoam
  123.         puts
  124.         free
  125.         print
  126.         byte    ",  ",0
  127.  
  128.         mov    ch, hour
  129.         mov    cl, minute
  130.         mov    dh, second
  131.         mov    dl, 0
  132.         ttoam
  133.         puts
  134.         free
  135.         printf
  136.         byte    ",   keystrokes = %d\n",0
  137.         dword    KeyStrokes
  138.         jmp    ReadLoop
  139.  
  140. ReadError:    print
  141.         byte    "Error reading file",cr,lf,0
  142.  
  143. Quit:        mov    bx, FileHandle
  144.         mov    ah, 3Eh            ;Close file
  145.         int    21h
  146.         ExitPgm
  147.  
  148. Main        endp
  149. cseg        ends
  150.  
  151. sseg        segment    para stack 'stack'
  152. stk        db    1024 dup ("stack   ")
  153. sseg        ends
  154.  
  155. zzzzzzseg    segment    para public 'zzzzzz'
  156. LastBytes    db    16 dup (?)
  157. zzzzzzseg    ends
  158.         end    Main
  159.